<html>
<head>

<link type="text/css" href="../css/style.css" rel="stylesheet"/>




<script type="text/javascript" src="../script/jquery.js"></script>
<script type="text/javascript" src="../script/jquery.validate.min.js"></script>
<script type="text/javascript" src="../script/messages_vi.js"></script>
<script type="text/javascript">
		$(document).ready(function(){
			$("#registerForm").validate({
				errorElement: "span",
				rules: {
					min_field: { min: 5 },
					max_field: { max : 10 },
					range_field: { range: [4,10] },
					rangelength_field: { rangelength: [4,10] }
				}
			});
            
            $("#user").keyup(function(){                   
                $.ajax({
                    url: '../script/check.php',
                    type: 'GET',
                    data: {
                        user: $("#user").val()
                    },
                    timeout: 4000,
                    error: function(xhr, ajaxOptions, thrownError){
                        alert(xhr.status);
                        alert(thrownError); 
                    },
                    success: function(msg){
                      $("#txtHint").html(msg);
                    }
                });
            });
            
            $("#submit").click(function(event){  
                if($("#txtHint").html() != "")
                    return false;
            });
		});
	</script>

<script type="text/javascript" src="../script/jsDatePick.jquery.min.1.3.js"></script>
<link rel="stylesheet" type="text/css" media="all" href="../css/jsDatePick_ltr.min.css" />
<script type="text/javascript">
		window.onload = function(){
    		new JsDatePick({
    			useMode:2,
    			target:"dob",
    			dateFormat:"%Y-%m-%d"
    		});
        };
</script>


<title>Register</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<center>
<h1>Dang ki</h1>
 <?php
    if(isset($_GET["type"])){
        $flag1 = 'hidden=""';
        $flag2 = '';
        $type = $_GET["type"];
        if($type == '4')
            $label = "Ngay sinh";
        else
            $label = "Ngay thanh lap";
    }
    else
    {
        $flag2 = 'hidden=""';
        $flag1 = '';
    }
?>
<input type="button" <?php echo $flag1;?> value="Nguoi tim viec" onclick="window.location.href='register.php?type=4'"/>
<input type="button" <?php echo $flag1;?> value="Nha tuyen dung" onclick="window.location.href='register.php?type=3'"/>
<form id="registerForm" name="registerForm" <?php echo $flag2;?> action="../action/registerAction.php" method="POST" enctype="multipart/form-data">
    <table>
     <?php
    if(isset($_GET["msg"])){
        $msg = $_GET["msg"];
        if($msg == "0")
            echo "<script>alert('Dang ki thanh cong')</script>";
        else
           echo "<script>alert('Dang ki that bai')</script>"; 
    }
    ?>
    <tr>
        <td style="text-align: right;">Ten dang nhap<span class="rq"> * </span></td><td><input class="required" type="text" name="user" id="user"/></td>
    </tr>
    <tr>
        <td></td>
        <td><span class="rq"> <div id="txtHint"> </span></td>
    </tr>
    <tr>
        <td style="text-align: right;">Mat Khau<span class="rq"> * </span></td><td><input class="required" minlength="8" type="password" name="pwd" /></td>
    </tr>
    <tr>
        <td style="text-align: right;"><?php echo $label; ?><span class="rq"> * </span></td><td><input class="required" type="text" name="dob" id="dob" /></td>
    </tr>
    <tr>
        <td style="text-align: right;">Gioi tinh:</td>
        <td>
            <select name="sex">
              <option value="1">Nam</option>
              <option value="0">Nu</option>
            </select>
        </td>
    </tr>
    <tr>
        <td style="text-align: right;">Anh dai dien<span class="rq"> * </span></td><td><input class="required" type="file" name="file" id="file" /></td>
    </tr>
    <tr>
        <td><span class="rq">(jpg,gif, <200kb) </span></td>
        <td><span class="rq"> <div id="imgHint"> </span></td>
    </tr>
    <tr>
        <td style="text-align: right;">Dien thoai<span class="rq"> * </span></td><td><input class="required number" type="text" name="phone" /></td>
    </tr>
    <tr>
        <td style="text-align: right;">Dia chi<span class="rq"> * </span></td><td><input class="required" type="text" name="add" /></td>
    </tr>
    <tr>
        <td style="text-align: right;">Email<span class="rq"> * </span></td><td><input class="required email" type="text" name="email" /></td>
    </tr>
    <tr>
        <td style="text-align: right;">Mo ta:</td><td><input type="text" name="descript" /></td>
    </tr>
    <tr>
        <td style="text-align: right;"></td><td><input type="hidden" name="type" value="<?php echo $type;?>"/></td>
    </tr>
    <tr>
        <td colspan="2" style="text-align: center;"><input type="submit" value="Dang Ki" id="submit"/></td>
    </tr>
    </table>
</form>
</center>
</body>
</html>
